package com.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.main.PicClient;
import com.main.ServiceInterfaceStub;

/**
 * Servlet implementation class FeedBack
 */
public class FeedBack extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FeedBack() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("In the FeedBackServlet");
		PrintWriter out=response.getWriter();
		// TODO Auto-generated method stub
		String url=request.getParameter("url");
		HttpSession session=request.getSession();
		String keyWord=(String)session.getAttribute("keywrd");
		PicClient client=(PicClient)session.getAttribute("object");
		String domain=(String)session.getAttribute("domain");
		String title=(String)session.getAttribute("title");
		String subTitle=(String)session.getAttribute("subTitle");
		
		
	/*	RequestHandlerStub.WriteToDB wTDB=new RequestHandlerStub.WriteToDB();
		wTDB.setUrl(url);
		
		RequestHandlerStub.WriteToDBResponse res= client.stub.writeToDB(wTDB);
		int i= res.get_return();*/
		ServiceInterfaceStub.SaveFeedback saveFB=new ServiceInterfaceStub.SaveFeedback();
		saveFB.setUrl(url);
		ServiceInterfaceStub.SaveFeedbackResponse res=client.stub.saveFeedback(saveFB);
		int i=res.get_return();
		System.out.println(url);
		System.out.println(keyWord);
		
	
		//String url= (request.getParameter("imageURL"));
		if(url!=null)
		{
		//out.println("<h1>'"+url+"'<h1/>");
			//out.println("<img src='"+url+"'/>");
			out.println("<img src='"+url+"'/>");
			
		}else
		{
		out.println("<h1>Url is null<h1/>");

		}
		System.out.println(url);
		System.out.println(keyWord);
	}

	

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
